/*
 * =====================================================================================
 *
 *       Filename:  cl_id.cxx
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  02/28/2011 04:44:43 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Ken Chen (Ken), chen_kenz@emc.com
 *        Company:  EMC
 *
 * =====================================================================================
 */

#ifndef __GXX_EXPERIMENTAL_CXX0X__
#define __GXX_EXPERIMENTAL_CXX0X__
#endif 

#include <cstdio>
#include <string>
#include "cl_id.hxx"

namespace neo
{
using namespace std;

atomic<uint64_t> CLId::m_currentId(0);

CLId::CLId(uint64_t id) 
  : m_id(id)
{
}

const CLId CLId::allocate(void) 
{
  return CLId(++m_currentId);
}

bool CLId::operator==(const CLId& id) const 
{
  return m_id == id.m_id;
}

const string CLId::toString(void) const
{
  char buf[10];  
  snprintf(buf, sizeof(buf), "%lu", (unsigned long)m_id);
  return buf;
}
} // neo

